#pragma once
//#include <Windows.h>
#include "GameConfig.h"
#include "HighPrecisionTimer.h"
#include <thread>
#include <atomic>

#define ISKEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) 

class HighPrecisionInput
{
	public:
	bool isRunning = false;
	atomic_flag queuelock = ATOMIC_FLAG_INIT;

	HighPrecisionInput(int keyscount, KEYCODE* pkeyset, HighPrecisionTimer* phptimer, float* curtime, int controllertype);
	~HighPrecisionInput() {};

	struct HPKEYEVENT
	{
		int indexInKeyset;
		bool keyevent; // true=keydown, false=keyup
		float time;
	};

	void start();
	void stop();
	HPKEYEVENT getkey();

	private:
	int keysetsize;
	bool* keystats;
	KEYCODE* pkeyset;
	HighPrecisionTimer* phptimer;
	float* curtime;
	int type;
	vector<HPKEYEVENT> keyqueue;

	void scankeys();

};